package com.xcity.game.combat.skill.impl;

import com.xcity.game.combat.Action;
import com.xcity.game.combat.ActionEffect;
import com.xcity.game.combat.CombatUtils;
import com.xcity.game.combat.buff.CombatBuff;
import com.xcity.game.combat.skill.CombatSkill;
import com.xcity.game.combat.unit.CombatUnit;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.skill.Skill;

/**
 * 迅疾无声<br/>
 * 哇哒！~一次强力的攻击，造成{0=220#0}%的技能伤害，若目标没有死亡则获得一层怒气，每层怒气增加{1=10#0}%技能伤害
 * @author yang.li
 *
 */
public class COMBAT_SKILL_90100 extends CombatSkill {

	protected int fury;
	
	public COMBAT_SKILL_90100(Skill skill) {
		super(skill);
	}

	@Override
	public void calcDamage(Action action) {
		CombatUnit source = action.unit;
		CombatUnit target = action.target.getDefenseUnit(action.unit.getIndex());
		if (target != null) {
			ActionEffect effect = action.addTarget(target);
			target = effect.getUnit(); // 修正目标
			float rate = skill.getParameter(0) / GameStaticConfig.percentBase + fury * skill.getParameter(1) / GameStaticConfig.percentBase;
//			int damage = (int) (source.getMagicPower() * rate - CombatUtils.calcMagicDefenseReduceDamage(target));
//			damage = CombatUtils.correctDamage(damage);
//			effect.effect(CombatAttribute.Type.HP, -damage);
			CombatUtils.calcMagicAttack(effect, rate);
			if (!target.isDied()) {
				action.addBuff(new BUFF(skill, source));
				fury++;
			}
		}
	}
	
	static class BUFF extends CombatBuff {
		public BUFF(Skill skill, CombatUnit owner) {
			super(skill.getTemplate().getCombatBuff(), owner);
		}
	}

}
